package com.h3c.ptability.utils;

import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public class ReturnDataUtil {

    private final JSONObject res = new JSONObject();

    public ResponseEntity<JSONObject> success() {
        res.put("msg", "成功");
        res.put("code", ReturnCodeData.SUCCESS);
        return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
    }

    public ResponseEntity<JSONObject> success(Object data, String message) {
        res.put("msg", message);
        res.put("data", data);
        res.put("code", ReturnCodeData.SUCCESS);
        return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
    }
    public ResponseEntity<JSONObject> success(Object data, String message,Object code) {
        res.put("msg", message);
        res.put("data", data);
        res.put("code", code);
        return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
    }

    public ResponseEntity<JSONObject> success(Object data) {
        res.put("msg", "成功");
        res.put("data", data);
        res.put("code", ReturnCodeData.SUCCESS);
        return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
    }

    public ResponseEntity<JSONObject> error() {
        res.put("msg", "失败");
        res.put("code", ReturnCodeData.FAIL);
        return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
    }

    public ResponseEntity<JSONObject> error(String message) {
        res.put("msg", message);
        res.put("code", ReturnCodeData.FAIL);
        return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
    }
}
